package com.Servlet;

import com.Service.Impl.UserServiceImpl;
import com.Service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Author: 冷俊杰
 * @Description: 根据ID删除用户
 * @DateTime: 2022/6/16 17:48
 **/
@WebServlet(name = "/DeleteUserServlet", value = "/DeleteUserServlet")
public class DeleteUserServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        UserService service = new UserServiceImpl();
        Integer id = Integer.parseInt(request.getParameter("id"));
        int i = service.deleteUser(id);
        System.out.println("结果"+i);
        request.getRequestDispatcher("./Recycle.jsp").forward(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
